/** 
 * use for icp amdin login
 * @name icp
 * @author yuyunxin511@163.com
 * @version 0.1.0
 */
timeout_s = 60000;
function req_ajax(postData, url, callback){
    $.ajax({
        type: "POST",
        url: url,
		async: false,//默认设置为true，所有请求均为异步请求
		data: postData,
        timeout: timeout_s,
        success: function(result, status){
            callback(result, status);
        },
        error: function(request, reCode, exception){
            if (reCode == 'timeout'){
                alert('响应超时，请重试！');
                return;
            }
        },
    });
};

function req_ajax_get(url, callback){
    $.ajax({
        type: "GET",
        url: url,
        timeout: timeout_s,
        success: function(result, status){
          	callback(result, status);
        },
        error: function(request, reCode, exception){
          if (reCode == 'timeout'){
              alert('响应超时，请重试！');
              return;
          }
		  alert('响应超时，请重试！');
        },
    });
};

function hideModal(modal_id){
    $("#"+modal_id).modal("hide");
    $("#"+modal_id).html("");
};

/* 全选 */
function sel_all(clickObj, tagName) {
	var val = $(clickObj).prop("checked");
    $(":checkbox").each(function(){
        if ($(this).prop("name") == tagName){
          $(this).prop("checked", val);
        }
    });
}

function get_select_ids(tagName){
    var sel_obj = new Object();
    sel_obj.ids = "";
    sel_obj.names = "";
    $(":checkbox").each(function(){
        if($(this).attr("name") == tagName){
            if($(this).prop("checked")==true || $(this).prop("checked")=='checked' ){
                var id = $(this).val();
                if (id != "" && id >= 0){
                    if(sel_obj.ids.length>0){
                        sel_obj.ids += ",";
                        sel_obj.names += ",";
                    }
                    sel_obj.ids += id;
                    var name = $.trim($("#name_"+tagName+"_"+id).html());
                    name = name.replace(/\n/g, "");
                    sel_obj.names += "\""+name+"\"" + "\n";
                }
            }
        }
    });
    return sel_obj;
};